String clazzTpl({package}) => """
import 'dart:convert';
import 'print_util.dart';
import 'package:crypto/crypto.dart';
import 'package:encrypt/encrypt.dart';
import 'package:pointycastle/asymmetric/api.dart';

class EncryptUtil {
  /// 本地数据缓存 AES key
  static const String _key = "b3By5FrQIDS9tK2q0wXsdmWHJouUVZkT";

  /// RSA加密
  static String? encryptRSA({
    required String publicKey,
    required String content,
  }) {
    RSAAsymmetricKey rsaAsymmetricKey =
        RSAKeyParser().parse(\"""-----BEGIN PUBLIC KEY-----
\$publicKey
-----END PUBLIC KEY-----\""");
    if (rsaAsymmetricKey.modulus != null && rsaAsymmetricKey.exponent != null) {
      RSAPublicKey rsaPublicKey =
          RSAPublicKey(rsaAsymmetricKey.modulus!, rsaAsymmetricKey.exponent!);
      final encrypter = Encrypter(RSA(publicKey: rsaPublicKey));
      return encrypter.encrypt(content).base64;
    }
    return null;
  }

  /// Base64编码
  static String encodeBase64(String data) {
    return base64Encode(utf8.encode(data));
  }

  /// Base64解码
  static String decodeBase64(String data) {
    return String.fromCharCodes(base64Decode(data));
  }

  /// MD5加密
  static String encodeMD5(String data) {
    final content = const Utf8Encoder().convert(data);
    return md5.convert(content).toString();
  }

  /// AES加密
  static String? encryptAES(String? content) {
    if (content == null) return null;
    try {
      final key = Key.fromUtf8(_key);
      final iv = IV.fromLength(16);
      final encrypter = Encrypter(AES(key, mode: AESMode.cbc));
      final encrypted = encrypter.encrypt(content, iv: iv);
      return encrypted.base64;
    } catch (e) {
      logDebugPrint("aes encode error:\$e");
    }
    return null;
  }

  /// AES解密
  static String? decryptAES(String? content) {
    if (content == null) return null;
    try {
      final key = Key.fromUtf8(_key);
      final iv = IV.fromLength(16);
      final encrypter = Encrypter(AES(key, mode: AESMode.cbc));
      final decrypted = encrypter.decrypt64(content, iv: iv);
      return decrypted;
    } catch (e) {
      logDebugPrint("aes decode error:\$e");
    }
    return null;
  }
}
""";
